package com.sw.small_world.fragment.base;

import android.support.v4.app.Fragment;

import com.sw.small_world.R;
import com.sw.small_world.fragment.home.BaseHomeFragment;
import com.sw.small_world.fragment.home.encyclopedia.EncyclopediaDetailFragment;
import com.sw.small_world.fragment.home.encyclopedia.EncyclopediaFragment;
import com.sw.small_world.fragment.home.HomeFragment;
import com.sw.small_world.fragment.home.encyclopedia.EncyclopediaListFragment;
import com.sw.small_world.fragment.home.persondoing.PersonDoingDetailFragment;
import com.sw.small_world.fragment.home.search.HomeSearchFragment;
import com.sw.small_world.fragment.home.persondoing.PersonDoingFragment;
import com.sw.small_world.fragment.home.search.SearchDoingFragment;
import com.sw.small_world.fragment.home.search.SearchResultFragment;
import com.sw.small_world.fragment.home.search.SearchTopicFragment;
import com.sw.small_world.fragment.home.search.SearchUserFragment;
import com.sw.small_world.fragment.home.smallmessage.SmallMessageDetailFragment;
import com.sw.small_world.fragment.home.smallmessage.SmallMessageFragment;
import com.sw.small_world.fragment.home.topicsquare.PersonInfoFragment;
import com.sw.small_world.fragment.home.topicsquare.TopicSquareDetailFragment;
import com.sw.small_world.fragment.home.topicsquare.TopicSquareFragment;
import com.sw.small_world.fragment.me.IntegralCenterFragment;
import com.sw.small_world.fragment.me.MeFragment;
import com.sw.small_world.fragment.me.MyAnswerFragment;
import com.sw.small_world.fragment.me.MyAskFragment;
import com.sw.small_world.fragment.me.mycircle.AddCircleFragment;
import com.sw.small_world.fragment.me.mycircle.CreateTagFragment;
import com.sw.small_world.fragment.me.mycircle.MyCircleFragment;
import com.sw.small_world.fragment.me.mycircle.MyCirclesFragment;
import com.sw.small_world.fragment.me.MyFriendsFragment;
import com.sw.small_world.fragment.me.MyPersonDoingFragment;
import com.sw.small_world.fragment.me.mysettings.MySettingFragment;
import com.sw.small_world.fragment.me.MySmallMessageFragment;
import com.sw.small_world.fragment.me.mycollect.MyCollectEncyclopediaFragment;
import com.sw.small_world.fragment.me.mycollect.MyCollectFragment;
import com.sw.small_world.fragment.me.mycollect.MyCollectTopicFragment;
import com.sw.small_world.fragment.me.myinfo.AddEduExFragment;
import com.sw.small_world.fragment.me.myinfo.AddJobExFragment;
import com.sw.small_world.fragment.me.myinfo.EditMyInfoFragment;
import com.sw.small_world.fragment.me.myinfo.MyInfoFragment;
import com.sw.small_world.fragment.message.AtMeFragment;
import com.sw.small_world.fragment.message.MessageCommentFragment;
import com.sw.small_world.fragment.message.MessageFragment;
import com.sw.small_world.fragment.message.PrivateMessageFragment;
import com.sw.small_world.fragment.publish.PublishNeedFragment;
import com.sw.small_world.fragment.publish.PublishQuestionFragment;
import com.sw.small_world.fragment.publish.PublishSmallMessageFragment;
import com.sw.small_world.fragment.smallworld.SmallWorldFragment;
import com.sw.small_world.utils.ConstantUtils;


/**
 * fragment的工厂类
 * zs on 2015/11/3.
 */
public class FragmentFactory {

    /**
     * 根据资源id返回不同的fragment
     */
    public static Fragment createById(int resId) {
        Fragment fragment = null;
        switch (resId) {
            // 首页
            case R.id.publish_small_message:
                fragment = new PublishSmallMessageFragment();
                break;
            case R.id.publish_question:
                fragment = new PublishQuestionFragment();
                break;
            case R.id.publish_need:
                fragment = new PublishNeedFragment();
                break;
            case R.id.home_search:
                fragment = new HomeSearchFragment();
                break;
            case R.id.home_topic_square:
                fragment = new TopicSquareFragment();
                break;
            case R.id.home_person_doing:
                fragment = new PersonDoingFragment();
                break;
            case R.id.home_small_message:
                fragment = new SmallMessageFragment();
                break;
            case R.id.home_encyclopedia:
                fragment = new EncyclopediaFragment();
                break;
            // 我的界面跳转
            case R.id.rl_my_info:
                fragment = new MyInfoFragment();
                break;
            case R.id.item_my_friends:
                fragment = new MyFriendsFragment();
                break;
            case R.id.item_my_circle:
                fragment = new MyCirclesFragment();
                break;
            case R.id.item_my_collection:
                fragment = new MyCollectFragment();
                break;
            case R.id.item_my_ask:
                fragment = new MyAskFragment();
                break;
            case R.id.item_my_answer:
                fragment = new MyAnswerFragment();
                break;
            case R.id.item_my_person_doing:
                fragment = new MyPersonDoingFragment();
                break;
            case R.id.item_my_small_message:
                fragment = new MySmallMessageFragment();
                break;
            case R.id.item_integral_center:
                fragment = new IntegralCenterFragment();
                break;
            case R.id.item_settings:
                fragment = new MySettingFragment();
                break;
            case R.id.rl_edit_my_info:
                fragment = new EditMyInfoFragment();
                break;
            case ConstantUtils.ADD_JOB_EX:
                fragment = new AddJobExFragment();
                break;
            case ConstantUtils.ADD_EDU_EX:
                fragment = new AddEduExFragment();
                break;
            case ConstantUtils.MY_CIRCLE:
                fragment = new MyCircleFragment();
                break;
            case ConstantUtils.CREATE_TAG:
                fragment = new CreateTagFragment();
                break;
            case R.id.add_circle:
                fragment = new AddCircleFragment();
                break;
            case ConstantUtils.ENCYCLOPEDIA_LIST:
                fragment = new EncyclopediaListFragment();
                break;
            case ConstantUtils.DETAIL_ENCYCLOPEDIA:
                fragment = new EncyclopediaDetailFragment();
                break;
            // 详情
            case ConstantUtils.DETAIL_TOPIC_SQUARE:
                fragment = new TopicSquareDetailFragment();
                break;
            case ConstantUtils.DETAIL_PERSON_DOING:
                fragment = new PersonDoingDetailFragment();
                break;
            case ConstantUtils.DETAIL_SMALL_MESSAGE:
                fragment = new SmallMessageDetailFragment();
                break;
            case ConstantUtils.PERSON_INFO:
                fragment = new PersonInfoFragment();
                break;
            case ConstantUtils.SEARCH_RESULT:
                fragment = new SearchResultFragment();
                break;
        }
        return fragment;
    }

    /**
     * main
     *
     * @param position
     * @return
     */
    public static Fragment createForMain(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:
                fragment = new BaseHomeFragment();
                break;
            case 1:
                fragment = new SmallWorldFragment();
                break;
            case 2:
                fragment = new MessageFragment();
                break;
            case 3:
                fragment = new MeFragment();
                break;
        }
        return fragment;
    }

    public static Fragment createForHome(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:
                fragment = new HomeFragment();
                break;
            case 1:
                fragment = new HomeSearchFragment();
                break;
            case 2:
                fragment = new TopicSquareFragment();
                break;
            case 3:
                fragment = new PersonDoingFragment();
                break;
            case 4:
                fragment = new SmallMessageFragment();
                break;
            case 5:
                fragment = new EncyclopediaFragment();
                break;
        }
        return fragment;
    }

    public static Fragment createForMessage(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:
//                fragment= SWApplication.getiMKit().getConversationFragment();
//                fragment = SWApplication.getiMKit().getContactsFragment();
                fragment = new PrivateMessageFragment();
                break;
            case 1:
                fragment = new MessageCommentFragment();
                break;
            case 2:
                fragment = new AtMeFragment();
                break;
        }
        return fragment;
    }

    public static Fragment createForSearch(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:
                fragment = new SearchTopicFragment();
                break;
            case 1:
                fragment = new SearchDoingFragment();
                break;
            case 2:
                fragment = new SearchUserFragment();
                break;
        }
        return fragment;
    }

    public static Fragment createForMyCollect(int position) {
        Fragment fragment = null;
        switch (position) {
            case 0:
                fragment = new MyCollectTopicFragment();
                break;
            case 1:
                fragment = new MyCollectEncyclopediaFragment();
                break;
        }
        return fragment;
    }
}
